package com.tycmc.signelectroniccontracts.logic.renzheng.qiye;

import android.content.Intent;

import com.tycmc.signelectroniccontracts.act.htong.ActHtList;
import com.tycmc.signelectroniccontracts.act.renzheng.qiye.FraDuiGongDakuan;
import com.tycmc.signelectroniccontracts.tools.base.LogicParent;
import com.tycmc.signelectroniccontracts.tools.manager.AppManager;
import com.tycmc.signelectroniccontracts.tools.net.NetUrl;
import com.tycmc.signelectroniccontracts.tools.net.NetWorkUtils;
import com.tycmc.signelectroniccontracts.tools.net.RequestAction;
import com.tycmc.signelectroniccontracts.tools.net.result.NetworkResult;
import com.tycmc.signelectroniccontracts.tools.other.TextShow;
import com.tycmc.signelectroniccontracts.tools.show.ProDialog;
import com.tycmc.signelectroniccontracts.tools.show.ToastShow;

import java.util.Map;

public class PreDuiGongDaKuan extends LogicParent {

    private DuiGongDaKuanInterface pre;
    private FraDuiGongDakuan fra;

    public PreDuiGongDaKuan(DuiGongDaKuanInterface pre) {
        this.pre = pre;
        fra = ((FraDuiGongDakuan) pre);
    }

    public void initData(Map upMap) {
        pre.initData(TextShow.valueOf(upMap.get("bankName")), TextShow.valueOf(upMap.get("bankAddress")), TextShow.valueOf(upMap.get("bankAccountNo")));
    }

    public void upData(Map upMap) {
        RequestAction action = new RequestAction(NetUrl.checkAmount);
        action.putBodyAll(upMap);
        final ProDialog dialog = new ProDialog(fra.getActivity(), "");
        dialog.show();
        new NetWorkUtils(fra.getActivity()).postJson(action, new NetworkResult() {
            @Override
            public void sucess(Map<String, Object> data, String str) {
                dialog.dismiss();
                ToastShow.popupToast("请求成功");
                fra.start(new Intent(fra.getActivity(), ActHtList.class));
                AppManager.getAppManager().finishAllActivity();
            }

            @Override
            public void failed(Object data) {
                ToastShow.popupToast(data+"");
                dialog.dismiss();
            }
        });
    }

    public interface DuiGongDaKuanInterface {
        void initData(String yinghangmingcheng, String yinghangdizhi, String yinghangzhanghao);
    }
}
